package edu.bw.service.Impl;

import edu.bw.config.SpringConfig;
import edu.bw.po.Product;
import edu.bw.service.ProductService;
import edu.bw.utils.TransactionManager;
import edu.bw.utils.TransactionProxyFactory;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import static org.junit.jupiter.api.Assertions.*;

@SpringJUnitConfig(SpringConfig.class)
class ProductServiceImplTest02 {

//    @Autowired
//    private ProductService productService;

    @Autowired
    private TransactionProxyFactory transactionProxyFactory;

    @Test
    void updateProduct() {
        ProductService proxyInstance =(ProductService) transactionProxyFactory
                .createProxyInstance(ProductServiceImpl.class);
        proxyInstance.updateProduct(new Product(13,"索尼单反相机",5999,"数码相机"));
    }

    @Test
    void findAll() {
        ProductService proxyInstance =(ProductService) transactionProxyFactory
                .createProxyInstance(ProductServiceImpl.class);
        proxyInstance.findAll().forEach(System.out::println);
    }
}